
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>消息持久化配置 - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>消息持久化配置 - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">RocketMQ的存储架构主要由哪三个核心文件组成？它们各自的作用是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">RocketMQ的存储架构主要由CommitLog、ConsumeQueue和IndexFile三个核心文件组成。CommitLog是核心存储文件，所有消息顺序写入其中；ConsumeQueue是CommitLog的索引文件，用于按主题和队列快速检索消息；IndexFile则提供根据消息Key查询消息的能力。</div>
          </div>
          <div class="card-source">来源: 1. 存储架构概述</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">简述RocketMQ中消费者的消息读取流程。</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">消费者请求消息后，Broker首先根据消费位点从ConsumeQueue中查找消息索引，然后根据索引中记录的物理偏移量从CommitLog文件中读取具体的消息内容，最后将消息返回给消费者。</div>
          </div>
          <div class="card-source">来源: 3. 消息读取流程</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">RocketMQ支持哪两种刷盘策略？它们在可靠性和性能方面有何区别？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">RocketMQ支持同步刷盘和异步刷盘。同步刷盘可靠性高，因为消息写入内存后会立即刷写到磁盘，但性能相对较低。异步刷盘性能高，因为消息写入内存后立即返回响应，但可靠性相对较低，如果在刷盘前宕机可能会丢失消息。</div>
          </div>
          <div class="card-source">来源: 4. 刷盘机制</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">CommitLog文件在RocketMQ持久化机制中扮演什么角色？它为什么采用顺序写入的设计？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">CommitLog是RocketMQ最核心的存储文件，所有的消息都按照写入顺序存储在CommitLog文件中，不做任何主题或队列的区分。采用顺序写入的设计是为了提高写入效率。</div>
          </div>
          <div class="card-source">来源: 1.1 CommitLog</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">ConsumeQueue文件的作用是什么？它的每个条目包含了哪些关键信息？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">ConsumeQueue是CommitLog的索引文件，按照主题和队列组织，为消息消费提供快速检索。每个条目固定大小为20字节，包含了三个关键信息：消息在CommitLog中的物理偏移量、消息的大小和消息Tag的哈希值。</div>
          </div>
          <div class="card-source">来源: 1.2 ConsumeQueue</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">优化</div>
          <div class="card-question">文档中提到了哪些硬件层面的优化方法来提升RocketMQ的持久化性能？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">优化</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">文档中提到的硬件优化方法包括：1. 使用SSD替代传统机械硬盘以获得更高的IOPS和更低的延迟；2. 使用RAID10等配置提高磁盘IO性能和可靠性；3. 增加内存以缓存更多的消息，从而减少磁盘IO。</div>
          </div>
          <div class="card-source">来源: 2.1 硬件优化</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">模式</div>
          <div class="card-question">针对金融、支付等对数据一致性要求极高的场景，文档推荐采用什么样的配置组合？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">模式</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">针对高可靠性场景（如金融、支付），文档推荐的配置组合是“同步刷盘 + 同步复制”。</div>
          </div>
          <div class="card-source">来源: 1. 生产环境配置建议</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">如何通过配置参数来改变RocketMQ的刷盘策略？请写出相关参数名和可选值。</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">可以通过配置参数 `flushDiskType` 来改变刷盘策略。其可选值有两个：`SYNC_FLUSH` 代表同步刷盘，`ASYNC_FLUSH` 代表异步刷盘。</div>
          </div>
          <div class="card-source">来源: 3. 刷盘策略配置</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">消息持久化主要从哪几个方面影响系统性能？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">消息持久化主要从三个方面影响性能：1. 磁盘IO影响，包括写入和读取延迟以及吞吐量限制；2. 内存占用，主要体现在页缓存和内存映射文件（mmap）；3. 刷盘策略影响，同步刷盘性能低但可靠性高，异步刷盘反之。</div>
          </div>
          <div class="card-source">来源: 1. 持久化对性能的影响</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
